package br.com.Servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class loginServlet
 */
@WebServlet("/loginServlet")
public class loginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */

	/**
	 * @throws IOException 
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest req ,HttpServletResponse res) throws IOException {
		// TODO Auto-generated method stub
		
		PrintWriter out = res.getWriter();
		
		String nome1 = req.getParameter("username");
		
		req.setAttribute("menssagem", "Cadastrado Realizado com Sucesso!");
		
		
		if(nome1.equals("marcos")){
			System.out.print(nome1);
			RequestDispatcher rd = req
				    .getRequestDispatcher("admin.jsp");
				try {
				    rd.forward(req,res);
				} catch (ServletException e) {
				    // TODO Auto-generated catch block
				    e.printStackTrace();
				} catch (IOException e) {
				    // TODO Auto-generated catch block
				    e.printStackTrace();
				}
		      
			
		}else{
		      RequestDispatcher rd = req.getRequestDispatcher("adminCliente.jsp");
				try {
				    rd.forward(req,res);
				} catch (ServletException e) {
				    // TODO Auto-generated catch block
				    e.printStackTrace();
				} catch (IOException e) {
				    // TODO Auto-generated catch block
				    e.printStackTrace();
				}
		      
       }
	}
		
		/*out.print("<html>");
			out.print("<body>");
				out.print("sdsadsadsad");
			out.print("</body>");
		out.print("</html>");*/
	


}
